package com.liyujie.dyeingmachine.mobile.dao;

import com.liyujie.dyeingmachine.mobile.entity.ReagentEntity;
import com.liyujie.dyeingmachine.mobile.entity.ReagentEntity_Table;
import com.raizlabs.android.dbflow.sql.language.SQLite;

import java.util.List;

public class ReagentEntityDao {

    private ReagentEntityDao() {
    }

    public static ReagentEntityDao getInstance() {
        return ReagentEntityDao.SingletonHolder.INSTANCE;
    }

    /**
     * 获取所有数据
     *
     * @return
     */
    public List<ReagentEntity> getAllList() {
        return SQLite
                .select()
                .from(ReagentEntity.class)
                .queryList();
    }

    /**
     * 清理所有数据
     */
    public void CleanAllData() {
        SQLite.delete().from(ReagentEntity.class).execute();
    }

    /**
     * 根据ID查询数据
     *
     * @param ReagentId
     */
    public ReagentEntity QueryDataByID(long ReagentId) {
        return SQLite.select()
                .from(ReagentEntity.class)
                .where(ReagentEntity_Table.ReagentId.eq(ReagentId))
                .querySingle();
    }


    private static final class SingletonHolder {
        private static final ReagentEntityDao INSTANCE = new ReagentEntityDao();
    }

}
